package com.hava.contentsale.dao;

import com.hava.contentsale.meta.ContentPO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by yanfa on 2016/11/10.
 */
public interface ContentDao {

    @Select("SELECT * FROM content")
    public List<ContentPO> findAll();

    @Select("SELECT * FROM content WHERE(id = #{param1})")
    public ContentPO findOne(Long id);

    //添加Options当Mybatis插入后，源插入对象会被注入id
    @Options(useGeneratedKeys=true,keyProperty = "id")
    @Insert("INSERT INTO content (id,price,title,icon,abstract,text) VALUES (#{id},#{price},#{title},#{icon},#{_abstract},#{text})")
    public Integer create(ContentPO content);

    @Update("UPDATE content SET price=#{price},title=#{title},icon=#{icon},abstract=#{_abstract},text=#{text} WHERE (id = #{id})")
    public void update(ContentPO content);

    @Delete("DELETE FROM content WHERE(id = #{param1})")
    public void delete(Long id);
}
